<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("modelConfigPath", "purchase");
%>
<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
	<style type="text/css">
	body{
		
		overflow: hidden;
	}
	.panel{margin-bottom:0px;}
</style>
<ul class="nav nav-tabs nav-tabs-component " style="margin-bottom: 0px;">
	<li class="active"><a href="#purchase-tab" data-toggle="tab" >订单详情</a></li>
	<li><a href="#purchaseRecord-tab" data-toggle="tab" >订单操作记录</a></li>
</ul>
<div class="tab-content">
	<div class="tab-pane active" id="purchase-tab">
		<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
		    <div class="detailed-navbar-content panel-body">
		    	
		        <t:form modelAttribute="purchase" action="/purchase/purchase/save" method="post" cssClass="form-horizontal">
		            <div class="hide">
		                <t:hidden path="purchaseId"/>
		                <t:hidden path="deleteMark"/>
		                
		            </div>
		          
		            <div class="panel-header" style="height:50px;margin:0 auto  ">
		            		<label style="color:red;font-size:1.6em;margin-left:20px;margin-top:5px"><t:provider packageName="purchase" enumClassName="PurchaseState" value="${purchase.purchaseState }"/></label><label  style="font-size:1.2em;margin-left:20px">采购单号 : ${purchase.purchaseNo }</label><label style="font-size:1.2em;margin-left:20px">供应商 :  ${purchase.supplier.supplierName }	</label><label style="font-size:1.2em;margin-left:20px">采购员 : ${purchase.purchaseName }	</label><label style="font-size:1.2em;margin-left:20px">采购日期 : <fmt:formatDate value="${purchase.createDate}" type="date" dateStyle="default" pattern="YY-MM-dd HH:mm"/>	</label>				
					</div>
					
					<div class="table-responsive" style="height:316px">
						<table class="cntable table table-bordered  " >
							<thead>
								<tr class="success" >
									<th style="width:50px">序号</th>
									
									<th style="width:120px">商品编码</th>
									<th style="width:120px">商品名称</th>
									<th style="width:120px">规格</th>
									<th style="width:60px">单位</th>
									<th style="width:60px">采购数</th>
									<th style="width:60px">采购单价(元)</th>
									<th style="width:60px">小计(元)</th>
								</tr>
							</thead>
							<tbody>
							
							<c:forEach var="purchaseCollocation" items="${purchaseCollocations}" varStatus="status">
								<tr  data-id="${purchaseCollocation.id }">
									<td>${status.index+1 }</td>
									<td>${purchaseCollocation.collocationNo }</td>
									<td>${purchaseCollocation.cargoName }</td>
									<c:if test="${purchaseCollocation.propertyNameOne ne null &&purchaseCollocation.propertyNameTwo ne null }">
										<td>${purchaseCollocation.propertyNameOne }*${purchaseCollocation.propertyNameTwo }</td>
									</c:if>
									<c:if test="${purchaseCollocation.propertyNameOne ne null &&purchaseCollocation.propertyNameTwo eq null }">
										<td>${purchaseCollocation.propertyNameOne }</td>
									</c:if>							
									<td>${purchaseCollocation.unit }</td>
									<td class="name_no">${purchaseCollocation.purchaseNumber }</td>
									<td class="name_no">${purchaseCollocation.purchasePrice }</td>
									<td class="name_no">${purchaseCollocation.purchaseNumber*purchaseCollocation.purchasePrice }</td>
								</tr>			
							</c:forEach>
							
												
							</tbody>
							<tfoot >
								<tr style="height:40px" >
									<th>合计</th>
									<th colspan="4"> </th>
							
									<th>${purchase.purchaseNum }</th>
									<th> </th>
									<th>${purchase.purchaseMoney }</th>
								</tr>
								
							</tfoot>
						</table>    
						</div>
		
						 <div class="row" style="margin-top:6px;">
							<div style="float:left;"><span style="padding-left:30px;">制单人：${purchase.createUserName }</span></div>
							<div style="float:right;"><span style="padding-right:35px;">其它金额：${purchase.otherMoney }</span></div>
						</div>
						<div class="row" style="margin-top:6px;">
							<div style="float:left;"><span style="padding-left:30px;">备注：${purchase.comment}</span></div>
							<div style="float:right;"><span style="padding-right:35px;">应付金额：<label style="color:red;font-size:1.6em">${purchase.otherMoney+ purchase.purchaseMoney}</label></span></div>
						</div>
						 <t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
							<t:button icon="icon-floppy-disk" onclick="printer()" laddaType="progress" cssClass="btn-info" csize="sm">打印</t:button>
						</t:panelFoot>
					
					
		        </t:form>
		    </div>
		
		</t:panel>
	</div>
	<div class="tab-pane" id="purchaseRecord-tab">
		<iframe id="purchaseRecordIframe" name="purchaseRecordIframe" scrolling="auto" frameborder="0"
				scrolling="yes" width="100%" height="100%"  data-src="<c:url value='/purchase/purchaseRecord/index?purchaseId=${purchase.purchaseId }'/>">
        </iframe>
	</div>
</div>



<script type="text/javascript">
$(function(){
	iframeLazyOpen();
	tabpaneResize();
})
function saveData(lBtn){
	if (!$("form:first").valid()){
		return;
	}
	lBtn.start();
	$("form:first").submit();
}	
function iframeLazyOpen(){
	$(".nav.nav-tabs.nav-tabs-component li a").click(function(){
		var iframeTab = $(this).attr("href");
		var iframeId = iframeTab.substring(0,iframeTab.indexOf("-")) + "Iframe";
		$(iframeId).attr("src",$(iframeId).attr("data-src"));
	});
}

function tabpaneResize(){
	$(".tab-pane").height($(window).height() - 50);
	
	$(window).bind("resize",function(){$(".tab-pane").height($(window).height() - 50)});
	
}
function printer(){
	var key=$("#purchaseId").val();

	top.openModal("/purchase/purchase/purchaseDetailPrint?key="+key,"purchasePrint_form","采购单打印",1200,450);
}



</script>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/cntable.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formtags.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>
